Skip to content

Fall back to Rancher CA bundles for HelmOps#4724

Merged
thardeck merged 7 commits into
mainfrom
implement_3845
Mar 17, 2026
Merged

Fall back to Rancher CA bundles for HelmOps#4724
thardeck merged 7 commits into
mainfrom
implement_3845

Conversation

@thardeck
Copy link
Copy Markdown
Collaborator

Resolve the CA bundle in the HelmOps controller and store it in BundleHelmOptions.CABundle so the agent can use it without needing access to cattle-system secrets. The agent service account only has access to its own namespace.

Also restart helmops pods in dev/update-controller-k3d so that redeployments pick up the new controller binary.

Refers to #3845

@thardeck thardeck self-assigned this Feb 27, 2026
@thardeck thardeck requested a review from a team as a code owner February 27, 2026 10:23
Copilot AI review requested due to automatic review settings February 27, 2026 10:23
@thardeck thardeck added this to Fleet Feb 27, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds HelmOps support for falling back to Rancher-managed CA bundle secrets (in cattle-system) by resolving the CA bundle in the controller and passing it through Bundle/BundleDeployment options so agents don’t need access to cattle-system secrets.

Changes:

  • Add CABundle to BundleHelmOptions (API + CRD + deepcopy) to carry a PEM CA bundle to the agent.
  • Resolve Rancher CA bundle in the HelmOps controller (and use it as fallback for chart version resolution) and have the agent use the pre-resolved bundle from HelmChartOptions.
  • Extend unit/integration/e2e tests and restart helmops pods in the k3d dev script.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/cert/cabundle.go Broadens CA bundle resolver to accept a client.Reader (read-only access).
pkg/apis/fleet.cattle.io/v1alpha1/bundle_types.go Adds helmOpCABundle field to API type for passing CA bundles.
pkg/apis/fleet.cattle.io/v1alpha1/zz_generated.deepcopy.go Ensures CABundle (byte slice) is deep-copied correctly.
internal/cmd/controller/helmops/reconciler/helmop_controller.go Resolves Rancher CA bundle in-controller; adds fallback CA logic for chart version lookup.
internal/cmd/controller/helmops/reconciler/helmop_controller_test.go Updates unit tests to account for Rancher CA lookup behavior.
internal/bundlereader/helm.go Agent uses controller-provided CA bundle from HelmChartOptions.CABundle when secret has none.
internal/bundlereader/helm_test.go Adds test coverage to validate CA bundle propagation via HelmChartOptions.
integrationtests/helmops/controller/suite_test.go Creates cattle-system namespace in envtest to support CA secret scenarios.
integrationtests/helmops/controller/controller_test.go Adds integration coverage for tls-ca / tls-ca-additional CA fallback.
e2e/single-cluster/helmop_test.go Adds an E2E case validating HelmOps Rancher CA fallback in a real cluster.
dev/update-controller-k3d Restarts helmops pods to pick up new controller builds during dev.
charts/fleet-crd/templates/crds.yaml Exposes the new helmOpCABundle field in generated CRDs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/cmd/controller/helmops/reconciler/helmop_controller.go
Comment thread internal/cmd/controller/helmops/reconciler/helmop_controller_test.go Outdated
Comment thread internal/cmd/controller/helmops/reconciler/helmop_controller_test.go Outdated
Comment thread internal/cmd/controller/helmops/reconciler/helmop_controller_test.go Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/bundlereader/helm_test.go Outdated
Comment thread internal/cmd/controller/helmops/reconciler/polling_job.go Outdated
Resolve the CA bundle in the HelmOps controller and store it in
BundleHelmOptions.CABundle so the agent can use it without needing
access to cattle-system secrets. The agent service account only has
access to its own namespace.

Also restart helmops pods in dev/update-controller-k3d so that
redeployments pick up the new controller binary.
The test relied on the OCI registry being untrusted when
InsecureSkipTLSVerify is false and no CA bundle is provided. Since
the Rancher CA bundle fallback now supplies the fleet CI root CA
(stored in cattle-system/tls-ca-additional), the Zot OCI registry
is trusted automatically and the chart deploys successfully.
@thardeck thardeck moved this to 👀 In review in Fleet Feb 27, 2026
@thardeck thardeck modified the milestones: v2.14.1, v2.15.0 Feb 27, 2026
Comment thread pkg/apis/fleet.cattle.io/v1alpha1/bundle_types.go Outdated
Comment thread e2e/single-cluster/helmop_test.go Outdated
Comment thread e2e/single-cluster/helmop_test.go
Comment thread integrationtests/helmops/controller/suite_test.go
Comment thread internal/cmd/controller/helmops/reconciler/helmop_controller.go Outdated
Comment thread internal/cmd/controller/helmops/reconciler/helmop_controller.go
Comment thread internal/bundlereader/helm.go Outdated
@thardeck thardeck requested a review from weyfonk March 4, 2026 13:44
thardeck added 3 commits March 4, 2026 15:41
Note that Rancher's cattle-system secrets may not exist in standalone
Fleet installations. Also use "CA bundle" consistently in the
bundlereader comment.
The CA bundle is stored in bundle.Spec.HelmOpOptions.CABundle before
handleVersion is called, so passing it again as a separate parameter
is redundant. Remove the parameter and read it from the bundle directly.
The version "0.1.0" is a literal in the HelmOp spec, not a resolved
constraint, so asserting it appears in status adds no signal.
@thardeck thardeck modified the milestones: v2.15.0, v2.14.1 Mar 6, 2026
Combine our CA bundle pre-fetch logic with main's event interface migration:
- Get bundle first to extract stored CA bundle (implement_3845)
- Pass CA bundle to getChartVersion as 4th parameter (implement_3845)
- Adopt new Eventf interface with corev1.EventTypeWarning (#4678)
- Update fail() to take eventAction parameter (#4678)
Copy link
Copy Markdown
Contributor

@weyfonk weyfonk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@thardeck thardeck merged commit f475cd0 into main Mar 17, 2026
48 of 50 checks passed
@thardeck thardeck deleted the implement_3845 branch March 17, 2026 09:46
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in Fleet Mar 17, 2026
@thardeck thardeck modified the milestones: v2.14.1, v2.15.0 Mar 17, 2026
thardeck added a commit that referenced this pull request Mar 17, 2026
* Fall back to Rancher CA bundles for HelmOps

Resolve the CA bundle in the HelmOps controller and store it in
BundleHelmOptions.CABundle so the agent can use it without needing
access to cattle-system secrets. The agent service account only has
access to its own namespace.

Also restart helmops pods in dev/update-controller-k3d so that
redeployments pick up the new controller binary.

* Remove obsolete OCI no-TLS negative test

The test relied on the OCI registry being untrusted when
InsecureSkipTLSVerify is false and no CA bundle is provided. Since
the Rancher CA bundle fallback now supplies the fleet CI root CA
(stored in cattle-system/tls-ca-additional), the Zot OCI registry
is trusted automatically and the chart deploys successfully.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants